package one.four.twelve;

import java.util.HashMap;
import java.util.Map;

public class Intersection {

	public static int inter(int[] a, int[] b) {
		int c = 0;
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for (int i = 0; i < a.length; i++) {
			m.put(a[i], 1);
		}
		for (int i = 0; i < b.length; i++) {
			if (m.containsKey(b[i])) {
				c++;
			}
		}
		return c;
	}

	public static void main(String[] args) {
		int[] a = { 1, 2, 3 };
		int[] b = { 2, 3, 4, 5, 6 };
		int c = inter(a, b);
		System.out.println(c);
	}

}
